from django.db import models

# Create your models here.
class User(models.Model):
    """用户表"""
    name = models.CharField(max_length=30, unique=True, verbose_name='用户名')
    password = models.CharField(max_length=30, verbose_name='密码')
    age = models.IntegerField(default=1, verbose_name='年龄')
    phone = models.CharField(max_length=11, verbose_name='手机号')
    mailbox = models.EmailField(verbose_name='电子邮箱', default='110@live.com')
    dates = models.DateTimeField(auto_now=True, verbose_name='添加时间')
    
    def __str__(self) -> str:
        return f"用户名: {self.name}, 密码: {self.password}, 年龄: {self.age}, 手机: {self.phone}, 邮箱: {self.mailbox}, 添加时间: {self.dates}"
    
    
    class Meta:
        """数据表重命名和后台显示方式"""
        db_table = 'user_use'
        # managed = True
        verbose_name = '用户表(user)'
        verbose_name_plural = '用户表(user)'
    